Rsyncd only needs a subset of all capabilities so create
a dedicated user with these capabilities. This is better from both a
security and an isolation perspective than running as root.
Build system: x86/64
Build-tested: x86/64-glibc
Run-tested: x86/64-glibc
Signed-off-by: John Audia <[email protected]>
PKG_NAME:=rsync
PKG_VERSION:=3.4.1
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://download.samba.org/pub/$(PKG_NAME)/src
SUBMENU:=File Transfer
TITLE:=Rsync daemon
DEPENDS:=+rsync
+ USERID:=rsyncd=976:rsyncd=976
URL:=https://rsync.samba.org/
endef
$(INSTALL_DATA) ./files/rsyncd.conf $(1)/etc/
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/rsyncd.init $(1)/etc/init.d/rsyncd
+ $(INSTALL_DIR) $(1)/etc/capabilities
+ $(INSTALL_DATA) ./files/rsyncd.json $(1)/etc/capabilities
endef
define Package/rrsync/description
start_service() {
procd_open_instance
procd_set_param command "$PROG" --daemon --no-detach
+ [ -x /sbin/ujail -a -e /etc/capabilities/rsyncd.json ] && {
+ procd_add_jail rsyncd
+ procd_set_param capabilities /etc/capabilities/rsyncd.json
+ procd_set_param user rsyncd
+ procd_set_param group rsyncd
+ procd_set_param no_new_privs 1
+ }
procd_close_instance
}
--- /dev/null
+{
+ "bounding": [
+ "CAP_NET_BIND_SERVICE",
+ "CAP_SYS_CHROOT",
+ "CAP_SETUID",
+ "CAP_SETGID",
+ "CAP_DAC_OVERRIDE"
+ ],
+ "effective": [
+ "CAP_NET_BIND_SERVICE",
+ "CAP_SYS_CHROOT",
+ "CAP_SETUID",
+ "CAP_SETGID",
+ "CAP_DAC_OVERRIDE"
+ ],
+ "ambient": [
+ "CAP_NET_BIND_SERVICE",
+ "CAP_SYS_CHROOT",
+ "CAP_SETUID",
+ "CAP_SETGID",
+ "CAP_DAC_OVERRIDE"
+ ],
+ "permitted": [
+ "CAP_NET_BIND_SERVICE",
+ "CAP_SYS_CHROOT",
+ "CAP_SETUID",
+ "CAP_SETGID",
+ "CAP_DAC_OVERRIDE"
+ ],
+ "inheritable": [
+ "CAP_NET_BIND_SERVICE",
+ "CAP_SYS_CHROOT",
+ "CAP_SETUID",
+ "CAP_SETGID",
+ "CAP_DAC_OVERRIDE"
+ ]
+}